n = int(input())
rectangles = []
all_x = set()
all_y = set()

# 读取输入并收集所有坐标点
for _ in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    # 确保x1<x2, y1<y2，只是调整了同一个矩形的坐标顺序，将坐标统一为左下-右上的方式存储
    if x1 > x2:
        x1, x2 = x2, x1
    if y1 > y2:
        y1, y2 = y2, y1
    rectangles.append((x1, y1, x2, y2))
    all_x.add(x1)
    all_x.add(x2)
    all_y.add(y1)
    all_y.add(y2)

# 离散化坐标，后续查找时仍然是成对查找
sorted_x = sorted(all_x)
sorted_y = sorted(all_y)

# 创建标记数组
width = len(sorted_x)
height = len(sorted_y)
grid = [[False] * (height - 1) for _ in range(width - 1)]

# 填充标记数组
for x1, y1, x2, y2 in rectangles:
    # 找到离散化后的索引
    idx_x1 = sorted_x.index(x1)
    idx_x2 = sorted_x.index(x2)
    idx_y1 = sorted_y.index(y1)
    idx_y2 = sorted_y.index(y2)

    # 标记覆盖区域
    for i in range(idx_x1, idx_x2):
        for j in range(idx_y1, idx_y2):
            grid[i][j] = True

# 计算总面积
total_area = 0
for i in range(width - 1):
    for j in range(height - 1):
        if grid[i][j]:
            dx = sorted_x[i + 1] - sorted_x[i]
            dy = sorted_y[j + 1] - sorted_y[j]
            total_area += dx * dy

print(total_area)
